# coding: utf-8
#
# -*- coding: UTF-8 -*-

import sys, getopt

def main(argv):
    global inputfile
    global outputfile
    global inputfiletmp
    inputfile = ''
    outputfile = ''
    inputfiletmp = ''
    try:
      #opts, args = getopt.getopt(argv,"hi:o:",["ifile=","ofile="])

      opts, args = getopt.getopt(argv,"hi:o:m:",["ifile=","ofile="])
      #“hi:o:m:”  h 表示是一个开关选项；"i:"和"o:" "m:"则表示后面应该带一个参数。

    except getopt.GetoptError:
      print ('test.py -i <inputfile> -o <outputfile> -m <inputfiletmp>')
      sys.exit(2)
    for opt, arg in opts:
      if opt == '-h':
         print ('test.py -i <inputfile> -o <outputfile> -m <inputfiletmp>')
         sys.exit()
      elif opt in ("-i", "--ifile"):
         inputfile = arg
      elif opt in ("-o", "--ofile"):
         outputfile = arg
      elif opt in ("-m"):
        inputfiletmp = arg
      elif opt not in ("-i"):
        inputfiletmp = arg
    print ('输入的文件为：', inputfile)
    print ('输出的文件为：', outputfile)
    print ('输入的文件为：', inputfiletmp)

if __name__ == "__main__":
   main(sys.argv[1:])
   print ('输入的文件为：', inputfile)
   print ('输出的文件为：', outputfile)
   print ('输入的文件为：', inputfiletmp)